package com.bwie.controller;

import com.bwie.pojo.Result;
import com.bwie.pojo.dto.MonthDto;
import com.bwie.pojo.po.CarMonth;
import com.bwie.pojo.po.Month;
import com.bwie.service.MonthService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Controller
@RequestMapping("/month")
public class MonthController {
    @Autowired
    private MonthService monthService;
    @ResponseBody
    @GetMapping("getMonthList")
    public PageInfo<Month> getMonthList(MonthDto monthDto){
        PageInfo<Month> pageInfo = monthService.getMonthList(monthDto);
        return pageInfo;
    }


    @ResponseBody
    @GetMapping("getMonthListById")
    public List<Month> getMonthListById(@RequestParam("parkId") Integer parkId){
        List<Month> list = monthService.getMonthById(parkId);
        return list;
    }
    @ResponseBody
    @GetMapping("selectMonthById")
    public Month selectMonthById(@RequestParam("monthId") Integer monthId){
        Month month = monthService.selectMonthById(monthId);
        return month;
    }


    @ResponseBody
    @PostMapping("addCarMonth")
    public Result addCarMonth(@RequestBody CarMonth carMonth){
        monthService.addCarMonth(carMonth);
       return Result.success();
    }

}
